package org.jsbd.boss.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.jsbd.boss.common.DataGridModel;
import org.jsbd.boss.dao.IMiguReadConfigDao;
import org.jsbd.boss.domian.MiguReadConfigBean;
import org.springframework.stereotype.Repository;

@Repository("miguReadConfigDao")
public class MiguReadConfigDaoImpl extends CrackBaseDao implements IMiguReadConfigDao {

	@Override
	public void saveMiguReadConfig(MiguReadConfigBean miguReadConfig) {
		super.insert("migu_read_config.insert_migu_read_config", miguReadConfig);
	}

	@Override
	public void updateMiguReadConfig(MiguReadConfigBean miguReadConfig) {
		super.update("migu_read_config.update_migu_read_config", miguReadConfig);
	}

	@Override
	public MiguReadConfigBean getMiguReadConfig(MiguReadConfigBean miguReadConfig) {
		return (MiguReadConfigBean) super.queryForObject("migu_read_config.select_migu_read_config_one", miguReadConfig);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<MiguReadConfigBean> getMiguReadConfigList(MiguReadConfigBean miguReadConfig) {
		return super.queryForList("migu_read_config.select_migu_read_config_list", miguReadConfig);
	}

	@Override
	public Map<String, Object> getMiguReadConfigListPage(DataGridModel page, MiguReadConfigBean form) {
		form = (form == null ? new MiguReadConfigBean() : form);
		form.setPageInfo(page);
		Map<String, Object> results = new HashMap<String, Object>();
		results.put("total", super.queryForCount("migu_read_config.select_migu_read_config_page_count", form));
		results.put("rows", super.queryForList("migu_read_config.select_migu_read_config_list", form));
		return results;
	}

	public Integer getMiguReadConfigCount(MiguReadConfigBean miguReadConfig) {
		return super.queryForCount("migu_read_config.select_migu_read_config_page_count", miguReadConfig);
	}

	public void deleteMiguReadConfig(MiguReadConfigBean miguReadConfig){
		super.update("migu_read_config.del_migu_read_config", miguReadConfig);
	}

	@Override
	public void updateMiguReadStatus(MiguReadConfigBean miguReadConfig) {
		super.update("migu_read_config.update_migu_read_status", miguReadConfig);
		
	}

	@Override
	public MiguReadConfigBean getByName(String name) {
		return (MiguReadConfigBean) super.queryForObject("migu_read_config.select_by_name", name);
	}

	@Override
	public void updateDaylimit(List<MiguReadConfigBean> configs) {
		super.batchUpdate("migu_read_config.UPDATE_DAY_LIMIT", configs);
	}
	
}
